/*******************************************************************************
 * Copyright (c) 2011 SYSTEMA GmbH.
 * All rights reserved.
 *
 * Contributors:
 *     SYSTEMA GmbH - initial API and implementation
 *******************************************************************************/
package de.sr.gwtdemo.client.widgets.busybox;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * BusyBox is indicating running tasks.
 * 
 * @author reinhard
 * @since 05.07.2011
 * @version $Revision$
 * 
 *          $LastChangedDate$ $LastChangedBy$
 */
public class BusyBox extends Composite {

	private static BusyBoxUiBinder uiBinder = GWT.create(BusyBoxUiBinder.class);

	private static BusyBox instance = null;

	@UiField
	Label loaderMessage;

	@UiField
	Image loaderImage;

	interface BusyBoxUiBinder extends UiBinder<Widget, BusyBox> {
	}

	public static BusyBox getInstance() {
		if (instance == null) {
			instance = new BusyBox();
		}
		return instance;
	}

	public BusyBox() {
		initWidget(uiBinder.createAndBindUi(this));
		setVisible(false);
	}

	public void setLoaderMessage(String text) {
		loaderMessage.setText(text);
		setVisible(!text.equals(""));
	}

}
